#! /bin/bash

# ----------------------------------------------------------------------------
#
# Plot in tmux in background.
#
# yqm_leaf@163.com
#
# 05/05/21
#
# ----------------------------------------------------------------------------

SCRIPT_NAME=$(basename $0)
DIR_NAME=$(dirname $0)
source "${DIR_NAME}/lib" 

PLOT_QUEUE=1
NUM_PLOTS=1
NUM_THREADS=4
PLOT_BUFFER=4608
TEMP_DIR="/mnt/temp"
PLOTS_DIR="/mnt/chia"
FARMER_PUBLIC_KEY="8d6405992136748b8c7fd647c41d9ec4867b24a8d6f76df740cdcc0604a4dd7dde91fe90a5437a7a918de4e280d5846a"
POOL_PUBLIC_KEY="b91dbc412355443194c6b992cf5c305557824523665ff73af11c8f36a8e517d40381c17aa8010d9bddf59538dc556104"
VENV_DIR="/root/chia-blockchain/chia-blockchain"

type tmux > /dev/null 2>&1 || { echo "Please install tmux first" ; exit 1 ; }

for i in $(seq 1 ${NUM_PLOTS}) ; do
    tmux new-session -d "cd ${VENV_DIR} ; . ./activate ; chia plots create -n \
        ${PLOT_QUEUE}  -r ${NUM_THREADS} -b ${PLOT_BUFFER} -f \
        ${FARMER_PUBLIC_KEY} -p ${POOL_PUBLIC_KEY} -t \
        ${TEMP_DIR} -d ${PLOTS_DIR} | tee $(gen_log_file)"
done
